﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
  public  class ThamSo_Data
    {
      KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
      public DataTable TaoBang(string sql)
      {
          return kn.taobang(sql);
      }
      public DataTable LayDuLieu()
      {
          return kn.LayDuLieu("Load_ThamSo");
      }
      public int Insert(ThamSo_Public obj)
      {
          int Npara = 4;
          string[] name = new string[Npara];
          object[] values = new object[Npara];
          name[0]="@TenThamSo";
          values[0]=obj.TenThamSo;
          name[1]="@SoLuongMuon";
          values[1]=obj.SoLuongMuon;
          name[2] = "@ThoiGianMuon";
          values[2] = obj.ThoiGianMuon;
          name[3] = "@Status";
          values[3] = obj.Status;

          return kn.update("Insert_ThamSo",name,values,Npara);
      }
      public int Update(ThamSo_Public obj)
      {
          int Npara = 5;
          string[] name = new string[Npara];
          object[] values = new object[Npara];
          name[0] = "@MaThamSo";
          values[0] = obj.MaThamSo;
          name[1] = "@TenThamSo";
          values[1] = obj.TenThamSo;
          name[2] = "@SoLuongMuon";
          values[2] = obj.SoLuongMuon;
          name[3] = "@ThoiGianMuon";
          values[3] = obj.ThoiGianMuon;
          name[4] = "@Status";
          values[4] = obj.Status;

          return kn.update("Update_ThamSo", name, values, Npara);
      }
      public int Delete(ThamSo_Public obj)
      {
          int Npara = 4;
          string[] name = new string[Npara];
          object[] values = new object[Npara];
          name[0] = "@TenThamSo";
          values[0] = obj.TenThamSo;

          return kn.update("Delete_ThamSo", name, values, Npara);
      }
    }
}
